package com.ruoyi.admin.train.controller;

import com.ruoyi.train.domain.ExamApplication;
import com.ruoyi.train.domain.Vo.ExamApplicationVo;
import com.ruoyi.train.service.IExamApplicationService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 提交考试申请Controller
 *
 * @author wusihao
 * @date 2023-04-02
 */
@CrossOrigin
@RestController
@RequestMapping("/adminExam/application")
public class adminExamApplicationController extends BaseController
{
    @Autowired
    private IExamApplicationService examApplicationService;


    /**
     * 查询提交考试申请列表
     */
    @ApiOperation("查询考试申请表列表")
    @GetMapping("/list")
    public TableDataInfo list(ExamApplicationVo examApplicationVo)
    {
        startPage();
        List<ExamApplicationVo> list = examApplicationService.selectadminExamApplicationVoList(examApplicationVo);
        return getDataTable(list);
    }

    /**
     * 获取提交考试申请详细信息
     */
    @ApiOperation("查看考试申请表详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        ExamApplicationVo data = examApplicationService.selectExamApplicationVoById(id);
        return success(data);
    }

    /**
     * 新增提交考试申请
     */
    @ApiOperation("新增考试申请表")
    @Log(title = "提交考试申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamApplication examApplication)
    {
        return toAjax(examApplicationService.insertExamApplication(examApplication));
    }

    /**
     * 删除提交考试申请
     */
    @ApiOperation("删除考试申请表")
    @Log(title = "提交考试申请", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {

        return toAjax(examApplicationService.deleteExamApplicationByIds(ids));
    }

    /**
     * 提交考试申请1
     */
    @ApiOperation("经办人提交考试申请")
    @Log(title = "学员信息", businessType = BusinessType.UPDATE)
    @PostMapping("/jiangbanrenSubmitExamApplication")
    public AjaxResult jingbanrenSubmitExamApplcation(@RequestBody ExamApplication examApplication)
    {
        return toAjax(examApplicationService.jingbanrenSubmitExamApplication(examApplication));
    }
}
